#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 8888

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["BG.Admin.WebApi/BG.Admin.WebApi.csproj", "BG.Admin.WebApi/"]
COPY ["BG.CodeGenerator/BG.CodeGenerator.csproj", "BG.CodeGenerator/"]
COPY ["Infrastructure/BG.Infrastructure.csproj", "Infrastructure/"]
COPY ["BG.Common/BG.Common.csproj", "BG.Common/"]
COPY ["BG.ServiceCore/BG.ServiceCore.csproj", "BG.ServiceCore/"]
COPY ["BG.Repository/BG.Repository.csproj", "BG.Repository/"]
COPY ["BG.Model/BG.Model.csproj", "BG.Model/"]
COPY ["BG.Service/BG.Service.csproj", "BG.Service/"]
COPY ["BG.Tasks/BG.Tasks.csproj", "BG.Tasks/"]
RUN dotnet restore "./BG.Admin.WebApi/BG.Admin.WebApi.csproj"
COPY . .
WORKDIR "/src/BG.Admin.WebApi"
RUN dotnet build "./BG.Admin.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./BG.Admin.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "BG.Admin.WebApi.dll"]